package com.nd.rj.common.login;

import android.graphics.drawable.Drawable;

import com.product.android.business.bean.UserInfo;

public class NdMiscCallbackListener{
    private static IProcessListener mOnProcessListener = null;
    
    private static ILoginProcessListener mOnLoginProcessListener = null;
    
    private static IGetCheckcodeListener mOnCheckcodeListener=null; 
    
    /**发送短信登录验证码监听*/
    private static ISendMsgCodeListener mSendMsgCodeListener = null;     
    
    public static void setProcessListener(IProcessListener processListener){
        mOnProcessListener = processListener;
    }
    
    public static void setLoginProcessListener(ILoginProcessListener processListener){
        mOnLoginProcessListener = processListener;
    }
    
    public static void setOnGetCheckcodeListener(IGetCheckcodeListener listener){
    	mOnCheckcodeListener=listener;
    }
    
    /**
     * 设置发送短信登录验证码监听
     * 
     * <br>Created 2014-9-4 下午7:55:25
     * @param listener  短信登录时的发送短信验证码完成回调
     * @author          linsj
     */
    public static void setSendMsgCodeListener(ISendMsgCodeListener listener){
        mSendMsgCodeListener = listener;
    }
    
    public static void onFinishLoginProcess(UserInfo user){
        if (mOnProcessListener != null){
            mOnProcessListener.onFinishLoginProcess(user);
        }
    }
    
    public static void onBeforeFinishLoginProcess(UserInfo user){
        if (mOnProcessListener != null){
            mOnProcessListener.onBeforeFinishLoginProcess(user);
        } 
    }
    
    public static boolean onLoginProcess(UserInfo user){
        if (mOnLoginProcessListener != null){
            return mOnLoginProcessListener.onLoginProcess(user);
        }
        return true;
    }
    
    public static void onDeleteUser(UserInfo user){
        if (mOnLoginProcessListener != null){
            mOnLoginProcessListener.onDeleteUser(user);
        } 
    }
    
    public static void onGetCheckcodeFinish(boolean bSuccess, int iErrCode, String strErrMsg,
            Drawable checkcode) {
        if (mOnCheckcodeListener != null) {
            mOnCheckcodeListener.onGetCheckcodeFinish(bSuccess, iErrCode, strErrMsg, checkcode);
        }
    }
    
    /**
     * 发送短信登录的短信验证码完成
     * 
     * <br>Created 2014-9-4 下午7:57:20
     * @param bSuccess              是否成功发送验证码
     * @param iErrCode              错误时的错误码
     * @param strErrMsg             如果错误，则以此为错误消息
     * @author       linsj
     */
    public static void onSendMsgCodeFinish(boolean bSuccess, int iErrCode, String strErrMsg){
        if (null != mSendMsgCodeListener){
            mSendMsgCodeListener.onSendMsgCodeFinish(bSuccess, iErrCode, strErrMsg);
        }
    }
    
    public static abstract interface IProcessListener
    {
      /*登陆结束后处理已经退出等待窗口*/
      public abstract void onFinishLoginProcess(UserInfo user);
      
      /*在结束登陆前(登陆窗口还没结束)*/
      public abstract void onBeforeFinishLoginProcess(UserInfo user);
      
    }
    
    public static abstract interface ILoginProcessListener
    {     
      /*登陆过程中处理还没退出登陆窗口*/
      public abstract boolean onLoginProcess(UserInfo user);
      /*删除用户回调*/
      public abstract void onDeleteUser(UserInfo user);
    }
    
    public static abstract interface IGetCheckcodeListener{
    	/**
    	 * 获取验证码完成回调
    	 * 
    	 * <br>Created 2014-10-31 下午4:46:51
    	 * @param bSuccess     是否成功
    	 * @param iErrCode     错误码
    	 * @param strErrMsg    错误消息
    	 * @param checkcode    图形验证码
    	 * @author       linsj
    	 */
        void onGetCheckcodeFinish(boolean bSuccess, int iErrCode, String strErrMsg,
                Drawable checkcode);
    }
    
    /**
     * 短信登录时的发送短信验证码完成回调
     * 
     * <br>Created 2014-9-4 下午3:54:23
     * @version  NdMiscCallbackListener
     * @author   linsj		
     *
     * @see 	 
     * 
     * Copyright(c) 2009-2014, TQ Digital Entertainment, All Rights Reserved
     *
     */
    public static abstract interface ISendMsgCodeListener{
        
        /**
         * 短信登录时的发送短信验证码完成回调
         * 
         * <br>Created 2014-9-4 下午7:48:15
         * @param bSuccess              调用服务端接口是否成功
         * @param iErrCode              错误时的错误码
         * @param strErrMsg             错误时，显示错误信息
         * @author          linsj
         */
        public abstract void onSendMsgCodeFinish(boolean bSuccess, int iErrCode, String strErrMsg);
    }

}
